<?php
include 'header.php';
?>
<div style="margin-left:20px">
<h2>Tags</h2>
</div>
<?php
if($tags->num_rows() > 0){
	if($produk->num_rows() > 0){
	
	  ?>
<div class="panel panel-primary">
	<div class="panel-heading">
		Tambah Tags
	</div>
		<form action="<?php echo base_url().'index.php/produk/insert_tag/' ?>" method="post">
		<select name="produk">
		<?php
		foreach($produk->result() as $produk){
		?>
		<option value="<?php echo $produk->id_produk; ?>"><?php echo $produk->nama_produk;?></option>
		
		<?php
		}
		?>
		</select>
		</p><input type="text" name="keyword" placeholder="Masukkan tags"></p>
		<p><button class="btn btn-primary btn-large" href="#">Masukkan Tag</button></p>
		</form>
		<div>
		</div>
		</div>
	</div>
<div class="panel panel-primary">
  <!-- Default panel contents -->
  <div class="panel-heading">
  Hapus dan Ubah Tags
  </div>
   <table class="table table-bordered">
		<colgroup>
		<col class="span1"></col>
		<col class="span7"></col>
		</colgroup>
		<thead> 
			<tr>
				<th>No</th>
				<th>Tag</th>
				<th colspan="2">Pilihan</th>	
			</tr>
		</thead>
		<tbody>
   <?php 
		$no=1;
		foreach($tags->result() as $rows){
   ?>
		<tr>
		<td><?php echo $no++;?></td>
		<td><?php echo $rows->keyword ?></td>
		<td>
		<form action="<?php echo base_url().'index.php/produk/hapus_tag/'.$rows->keyword; ?>" method="post">
		<button class="btn btn-primary btn-large" href="#">Hapus</button>
		</form>
		</td>
		<!--<a href="<--?php echo base_url().'index.php/produk/hapus_tag/'.$rows->keyword; ?>">Hapus Tag</a>-->
		<td>
		<button class="btn btn-primary btn-large" href="#" onclick="edit('<?php echo $rows->keyword; ?>')">Edit</button>
		
		<!--<a href="<--?php echo base_url().'index.php/produk/edit_tag/'.$rows->keyword; ?>">Edit Tag</a>-->
		</td>
		</tr>
		<?php
			}	
		
		?>
		</tbody>
	</table>
   </div>
   <div class="panel panel-primary" style="display:none" id="kolom_edit">
	<div class="panel-heading" >
	kolom edit
	</div>
		<form action="<?php echo base_url().'index.php/produk/edit_tag/' ?>" method="post" >
		</p><input type="hidden" name="keyword_lama" placeholder="Masukkan tags" id="tag_lama"></p>
		</p><input type="text" name="keyword_baru" placeholder="Masukkan tags" id="tag_baru"></p>
		<button class="btn btn-primary btn-large" href="#">Edit</button>
		</form>
	
	</div>
	<a href="<?php echo base_url().'index.php/produk/' ?>">Kembali ke halaman awal</a>
	
	<script>$(document).ready();
	function edit(nama_tag){ if($('#tag_baru').val()!=nama_tag){		
										$('#tag_baru').val(nama_tag); $('#tag_lama').val(nama_tag); $("#kolom_edit").css("display","block");
										} else{
											$('#tag_baru').val(''); $('#tag_lama').val(''); $("#kolom_edit").css("display","none");
												}
									}
	</script>


<?php
}
}
?>